# for i in range(2):
#     print(i)  0 1
T = int(input())
ns = [int(input()) for _ in range(T)]

for idx, n in enumerate(ns):
    half = n // 2
    # 上半部分（包括中间行）
    for i in range(half + 1):
        spaces = ' ' * (half - i)
        stars = '*' * (2 * i + 1)
        print(spaces + stars)
    # 下半部分
    for i in range(half - 1, -1, -1):
        spaces = ' ' * (half - i)
        stars = '*' * (2 * i + 1)
        print(spaces + stars)
    if idx != len(ns) - 1:
        print()
